import request from '@/utils/request'

/**
 * 统一的AI对话接口
 * @param {Object} data - {handler_name, user_message, engine, context_data, chat_history}
 */
export function aiChat(data) {
  return request({
    url: '/cms/api/ai_chat/',
    method: 'post',
    data
  })
}

/**
 * 获取handler的预设问题列表
 * @param {String} handlerName - handler名称
 */
export function getHandlerPrompts(handlerName) {
  return request({
    url: `/cms/api/ai_chat/prompts/${handlerName}/`,
    method: 'get'
  })
}

/**
 * 列出所有可用的handler
 */
export function listHandlers() {
  return request({
    url: '/cms/api/ai_chat/handlers/',
    method: 'get'
  })
}

/**
 * 优化提示词
 * @param {Object} data - {prompt, ai_type}
 */
export function optimizePrompt(data) {
  return request({
    url: '/cms/api/ai_optimize_prompt/',
    method: 'post',
    data
  })
}
